# coding: utf-8
from datetime import datetime
from sqlalchemy import Column, String, Table, Text, DATETIME
from sqlalchemy.dialects.mysql import INTEGER
from ..database import db,serialize


class Log(db.Model):
    __tablename__ = 'logs'

    id = Column(INTEGER(11), primary_key=True)
    admin_id = Column(INTEGER(11), nullable=False, index=True)
    user = Column(String(50, 'utf8mb4_unicode_ci'), nullable=False)
    method = Column(String(20, 'utf8mb4_unicode_ci'), nullable=False)
    action_name = Column(String(255, 'utf8mb4_unicode_ci'), comment='操作名')
    url = Column(String(200, 'utf8mb4_unicode_ci'), nullable=False)
    data = Column(Text(collation='utf8mb4_unicode_ci'))
    created_at = Column(DATETIME, default=datetime.now())
